import React, {Component} from 'react';
import {hot} from 'react-hot-loader/root';
import {routerRedux} from 'dva/router';
import {connect} from 'dva';
import {Skeleton, message} from 'antd';
import QueryForm from '@/components/QueryForm';
import config, {commonConfig} from '@/config/queryform.config';

@connect(({global}) => ({
    global
}))
class RouteQueryForm extends Component {
    constructor(props) {
        super(props);
        this.state = {
            queryFormLoading: false
        };
    }

    changeTabgs = val => {
        const {dispatch} = this.props;
        dispatch(routerRedux.push(val));
    };
    onSubmit = data => {
        this.setState({queryFormLoading: true});
        window.setTimeout(() => {
            this.setState({queryFormLoading: false});
            message.success('查询成功');
            console.log(data);
        }, 3000);
    };
    render() {
        const newConfig = commonConfig({
            data: {},
            mapSource: [],
            disabled: false,
            options: {}
        });
        return (
            <section>
                <QueryForm config={newConfig} buttonLoading={this.state.queryFormLoading} onSubmit={this.onSubmit} />
                <section className="bg-fff ui-p-15 ui-mt-15">
                    <Skeleton paragraph={{rows: 4}} />
                </section>
            </section>
        );
    }
}

export default hot(RouteQueryForm);
